<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('主子表提交')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
    <div class="main-content">
        <form class="form-horizontal m" id="form-serinfo-edit" th:object="${lmSerinfo}">
            <input name="id" th:field="*{id}" type="hidden">
            <h4 class="form-header h4">服务信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所属服务类型：</label>
                        <div class="col-sm-8">
                            <input name="userId" th:field="*{serviceTypeName}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">用户名称：</label>
                        <div class="col-sm-8">
                            <input name="userId" th:field="*{userName}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">服务标题：</label>
                        <div class="col-sm-8">
                            <input name="serviceTitle" th:field="*{serviceTitle}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                </div>
            </div>
            <h4 class="form-header h4">服务案例</h4>
            <div class="row">
                <div class="col-sm-12">
                   <!-- <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>-->
                    <div class="col-sm-12 select-table table-striped">
					    <table id="bootstrap-table"></table>
					</div>
                </div>
            </div>
        </form>
    </div>
      
    <div class="row">
       <!-- <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>-->
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
	<script th:inline="javascript">
        var prefix = ctx + "lm/serinfo";
	    $(function() {
		    var options = {
                url: prefix + "/listChild",
                pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
		        columns: [{
		            checkbox: true
		        },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
		        {
		            field: 'casePic',
		            align: 'center',
		            title: '案例主图',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control' type='text' name='serinfoCase[%s].casePic' value='%s'>", index, value);
		        		return html;
                    }
		        },
		        {
		            field: 'caseTitle',
		            align: 'center',
		            title: '案例标题',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control' type='text' name='serinfoCase[%s].caseTitle' value='%s'>", index, value);
		        		return html;
                    }
		        },
		        /*{
		            field: 'date',
		            align: 'center',
		            title: '商品日期',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control' type='text' name='goods[%s].date' value='%s' placeholder='yyyy-MM-dd'>", index, value);
		        		return html;
                    }
		        },
		        {
		            field: 'price',
		            align: 'center',
		            title: '商品价格',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control' type='text' name='goods[%s].price' value='%s'>", index, value);
		        		return html;
                    }
		        },*/
		 /*       {
		            field: 'caseDes',
		            align: 'center',
		            title: '案例描述',
		            formatter: function(value, row, index) {
		        		var data = [{ index: index, type: value }];
		                return $("#goodsTypeTpl").tmpl(data).html();
                    }
		        }*/]
		    };
		    $.table.init(options);
		});
	    
	    /* 主子表-提交 */
        function submitHandler(index, layero){
        	var data = $("#form-add").serializeArray();
			$.operate.saveModal("/demo/operate/customer/add", data);
        }
	    
        $("input[name='birthday']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        function bindDatetimepicker() {
	        $("input[name$='date']").datetimepicker({
	            format: "yyyy-mm-dd",
	            minView: "month",
	            autoclose: true,
	            pickerPosition:'top-right'
	        });
        }
        
        function addColumn() {
        	var count = $("#" + table.options.id).bootstrapTable('getData').length;
        	sub.editColumn();
        	
        	$("#" + table.options.id).bootstrapTable('insertRow', {
        		index: count,
                row: {
                	index: $.table.serialNumber(count),
                	name: "",
                	weight: "",
                	price: "",
                	date: "",
                	type: "",
                }
        	});
            
        	bindDatetimepicker();
        }
    </script>
</body>
</html>

<!-- 商品类型 -->
<script id="goodsTypeTpl" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='goods[${index}].type'>
    <option value="">所有</option>
    <option value="0" {{if type==="0"}}selected{{/if}}>寒性</option>
    <option value="1" {{if type==="1"}}selected{{/if}}>热性</option>
</select>
</div>
</script>